package com.ks.util;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * Title: WASU Platform Description: 特殊分页的实现?
 *
 * @version 2.0
 */
public class Page {

    public static Map<String, Integer> getCount(int page, int size, int bx, int ll, int tl) {
        Map<String, Integer> map = new HashMap<>();
        int bxcount = 0;
        int llcount = 0;
        int tlcount = 0;
        int count = (page - 1) * size;
        int i = 0;
        if (bx != 0) {
            i = i + 1;
        }
        if (ll != 0) {
            i = i + 1;
        }
        if (tl != 0) {
            i = i + 1;
        }
        if (i != 0) {
            int per = size / i;
            if (bx >= per) {
                bxcount = per;
                if (ll >= per) {
                    llcount = per;
                } else {
                    llcount = ll - count;
                }
                tlcount = size - bxcount - llcount;
            } else {
                bxcount = bx;
                if (ll >= per) {
                    llcount = per;
                } else {
                    llcount = ll - count;
                }
                tlcount = size - (bxcount - count) - (llcount - count);
            }
            map.put("bx", bxcount);
            map.put("ll", llcount);
            map.put("tl", tlcount);
        } else {
            return null;
        }

        return map;

    }

}